/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.schedule.core.service.processor.edit;

import cn.hutool.core.lang.Assert;
import info.peigen.hotpot.common.core.result.ResultCode;
import info.peigen.hotpot.common.service.base.exception.BusinessException;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import info.peigen.hotpot.component.schedule.core.domain.ScheduleJob;
import info.peigen.hotpot.component.schedule.core.domain.action.ScheduleJobConvertor;
import info.peigen.hotpot.component.schedule.core.service.processor.AbstractScheduleServiceProcessor;
import info.peigen.hotpot.component.schedule.facade.command.result.ScheduleJobEditResult;
import org.noear.solon.annotation.Component;

/**
 * <b>(ScheduleJobEditResultProcessor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/1/7
 */
@Component
public class ScheduleJobEditResultProcessor extends AbstractScheduleServiceProcessor implements Processor {
    @Override
    public Integer level() {
        return 91;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {
        ScheduleJob domain = (ScheduleJob) serviceContext.getDomain();
        Assert.notNull(domain, () -> new BusinessException(ResultCode.FAILURE, "ScheduleJob不得为空[order=" + serviceContext.getOrder() + "]"));
        ScheduleJobEditResult result = (ScheduleJobEditResult) serviceContext.getResult();
        result.fromSuccess(ScheduleJobConvertor.convertToInfo(domain));
    }
}